package com.bdqn.controller;

import com.alibaba.fastjson.JSONObject;
import com.bdqn.pojo.AppCategory;
import com.bdqn.pojo.DataDictionary;
import com.bdqn.service.AppCategoryService;
import com.bdqn.service.DataDictionaryService;
import org.springframework.http.HttpRequest;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("/xia")
public class XiaLaController extends BaseController{
    @Resource
    private DataDictionaryService dataDictionaryService;
    @Resource
    private AppCategoryService appCategoryService;



    @RequestMapping(value="/zhuang",method = RequestMethod.GET)
    @ResponseBody
    public String getZhuang(Model model, HttpSession session){

        List<DataDictionary> grades = dataDictionaryService.listData("1");
        return JSONObject.toJSONString(grades);
    }

    @RequestMapping(value="/ping",method = RequestMethod.GET)
    @ResponseBody
    public String getUserList(Model model, HttpSession session){

        List<DataDictionary> grades = dataDictionaryService.listData("2");
        return JSONObject.toJSONString(grades);
    }

    @RequestMapping(value="/one",method = RequestMethod.GET)
    @ResponseBody
    public String getOne(){

        List<AppCategory> grades = appCategoryService.listAppC(1,0,0);
        return JSONObject.toJSONString(grades);
    }

    @RequestMapping(value="/two",method = RequestMethod.GET)
    @ResponseBody
    public String getTwo(HttpServletRequest request){
   Integer id=Integer.parseInt(request.getParameter("two"));

        List<AppCategory> grades = appCategoryService.listAppC(0,id,0);
        return JSONObject.toJSONString(grades);
    }
    @RequestMapping(value="/three",method = RequestMethod.GET)
    @ResponseBody
    public String getThree(HttpServletRequest request){
        Integer id=Integer.parseInt( request.getParameter("three"));
        List<AppCategory> grades = appCategoryService.listAppC(0,0,id);
        return JSONObject.toJSONString(grades);
    }


}
